package com.kuang.swagger.controller;

import com.kuang.swagger.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

@Api(value = "用户Controller", tags = "用户操作接口")
@RestController
public class HelloController {
    @GetMapping(value = "/hello")
    public String hello() {
        return "hello";
    }

    // 只要我们的接口中，返回值中存在实体类，他就会被扫描到Swagger中
    @PostMapping(value = "/user")
    public User user() {
        return new User();
    }

    // Operation接口，放在方法中
    @ApiOperation("Hello控制方法")
    @GetMapping("/hello2")
    public String hello(@ApiParam("用户名") String username) {
        return "hello" + username;
    }

    // Operation接口，放在方法中
    @ApiOperation("user控制方法")
    @GetMapping("/user2")
    public User getUser(@ApiParam("用户名") User user) {
        return user;
    }

    // Operation接口，放在方法中
    @ApiOperation("user控制方法")
    @RequestMapping(value = "/post/user2", method = RequestMethod.POST)
    public User postUser2(@ApiParam("用户名") @RequestBody User user) {
        return user;
    }
}
